package com.travel.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.travel.dao.RoomDao;
import com.travel.dao.impl.RoomDaoImpl;
import com.travel.entity.Room;
import com.travel.service.RoomService;
import com.travel.util.PageInfo;

public class RoomServiceImpl implements RoomService {
	private RoomDao roomDao = new RoomDaoImpl();

	@Override
	public boolean getInsertRoom(Room room) {
		int i = roomDao.insertRoom(room);
		return i == 1 ? true : false;
	}

	

	@Override
	public boolean getUpdateRoom(int roomId, Room room) {
		int i = roomDao.updateRoom(roomId, room);
		return i == 1 ? true : false;
	}

	/**
	 * 据当前页码、每页显示个数、酒店名查询酒店记录查询客房
	 * @throws SQLException 
	 */
	@Override
	public PageInfo<Room> queryRoomByPageAndName(int pageNum, int pageSize, String hotelName) throws SQLException {
		
		PageInfo<Room> pageInfo = roomDao.queryRoomByPageAndName(pageNum, pageSize, hotelName);
		
		return pageInfo;
	}



	@Override
	public boolean deleteRoomByIdSuccessOrNot(int roomId) {

		int i = roomDao.deleteRoom(roomId);
		return i == 1 ? true : false;
	}
	
	
	@Override
	public List<Room> getRoomById(int roomId) throws SQLException {
		
		return roomDao.getRoomById(roomId);
	}



	@Override
	public boolean modifyRoomWithNoPictureSuccessOrNot(Room room) {

		int i = roomDao.modifyRoomWithNoPicture(room);
		return i == 1 ? true : false;
	}

	@Override
	public boolean modifyRoomWithPictureSuccessOrNot(Room room) {

		int i = roomDao.modifyRoomWithPicture(room);
		return i == 1 ? true : false;
	}
	
	
	@Override
	public List<Room> queryRoomsByHotelId(int hotelId) {
		
		return roomDao.queryRoomsByHotelId(hotelId);
	
	}
	
//	@Override
//	public List<Room> queryAllRooms() {
//		List<Room> list = roomDao.queryAllRooms();
//		return list;
//	}

}
